// miniprogram/pages/audit/list.js
Page({
  data: {
    pendingRecords: [],
    sceneType: '',
    isAuditor: false,
    auditorLevel: 0
  },

  onLoad() {
    const app = getApp()
    this.setData({
      sceneType: app.globalData.sceneType,
      isAuditor: app.globalData.isAuditor,
      auditorLevel: app.globalData.auditorLevel
    })
    this.loadPendingRecords()
  },

  onShow() {
    this.loadPendingRecords()
  },

  loadPendingRecords() {
    // 模拟待审核记录数据
    const pendingRecords = [
      { 
        id: 1, 
        userName: '张三', 
        ruleName: '完成家务', 
        points: 10, 
        description: '打扫客厅和厨房', 
        createdAt: '2023-05-15 18:30',
        currentLevel: 1,
        maxLevel: 3
      },
      { 
        id: 2, 
        userName: '李四', 
        ruleName: '运动健身', 
        points: 15, 
        description: '跑步30分钟', 
        createdAt: '2023-05-15 19:00',
        currentLevel: 2,
        maxLevel: 3
      }
    ]
    
    this.setData({ pendingRecords })
  },

  viewRecord(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/audit/detail?id=${id}`
    })
  }
})